<template>
  <div class="grade-appeal">
    <div class="appeal-header">
      <h2>成绩申诉</h2>
    </div>

    <el-card>
      <el-table :data="appeals" v-loading="loading" stripe>
        <el-table-column prop="student" label="学生" width="120" />
        <el-table-column prop="exam" label="考试" width="150" />
        <el-table-column prop="reason" label="申诉原因" />
        <el-table-column prop="status" label="状态" width="100">
          <template #default="{ row }">
            <el-tag :type="getStatusType(row.status)">
              {{ row.status }}
            </el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="150">
          <template #default="{ row }">
            <el-button size="small" @click="reviewAppeal(row)">审核</el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { ElMessage } from 'element-plus'

const loading = ref(false)
const appeals = ref([])

const fetchAppeals = async () => {
  loading.value = true
  try {
    // TODO: 实现申诉列表API
    appeals.value = []
  } catch (error) {
    console.error('获取申诉列表失败:', error)
  } finally {
    loading.value = false
  }
}

const getStatusType = (status: string) => {
  switch (status) {
    case 'pending': return 'warning'
    case 'approved': return 'success'
    case 'rejected': return 'danger'
    default: return 'info'
  }
}

const reviewAppeal = (appeal: any) => {
  ElMessage.info('审核申诉功能开发中')
}

onMounted(() => {
  fetchAppeals()
})
</script>

<style scoped lang="scss">
.grade-appeal {
  padding: 20px;
}

.appeal-header {
  margin-bottom: 20px;

  h2 {
    margin: 0;
    color: #303133;
  }
}
</style>